package com.doge.calcalbum.utils

import android.net.Uri
import android.os.Build
import android.text.Html
import android.text.Spanned
import androidx.core.content.FileProvider
import java.io.File


object ApiCompat {
    private val fileProvider by lazy { "${appContext.packageName}.fileprovider" }
    fun getUri(file: File): Uri {
        if (Build.VERSION.SDK_INT >= 24) {
            return FileProvider.getUriForFile(
                appContext,
                fileProvider,
                file
            )
        }
        return Uri.fromFile(file)
    }

    fun fromHtml(text: String): Spanned {
        if (Build.VERSION.SDK_INT >= 24) {
            return Html.fromHtml(text, Html.FROM_HTML_MODE_COMPACT)
        }
        return Html.fromHtml(text)
    }
}
